@echo off
setlocal enabledelayedexpansion
set PID_FILE=application.pid

if not exist "%PID_FILE%" (
    echo PID文件不存在，服务可能未启动 >logs/stop.log
    exit /b 1
)

set /p PID=<%PID_FILE%
tasklist /FI "PID eq %PID%" | findstr /C:"%PID%" >logs/stop.log
if %ERRORLEVEL% equ 0 (
    taskkill /F /PID %PID% 
    echo 已终止进程PID: %PID% >logs/stop.log
    del "%PID_FILE%" /Q
) else (
    echo 进程%PID%不存在，可能已停止 >logs/stop.log
    del "%PID_FILE%" /Q
)